//封装分类数据业务相关代码
import { getCategoryApi } from '@/apis/category'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'

export function useCategory() {
    const categoryData = ref({})
    //获取路由对象
    const route = useRoute()
    const getCategory = async (id = route.params.id) => {

        const res = await getCategoryApi(id)//传递路由过来的params数据
        categoryData.value = res.result
    }
    onMounted(() => getCategory())
    return { categoryData, getCategory }
}